<?php
class RegisterForm extends sfForm {

    public function setup()
    {
        $this->disableLocalCSRFProtection();

        $this->setWidgets(array(
            'user' => new sfWidgetFormInputText(),
        	'password' => new sfWidgetFormInputPassword()
        ));


        $this->setValidators(array(
			'user' => new sfValidatorAnd(array(
				new sfValidatorString(array('required' => true)),
				new sfValidatorRegex(array('pattern' => '/^[0-9A-Za-z_.-]+$/'),array('invalid'=>'Dozwolone znaki to: a-zA-Z0-9_-.'))
			),array(),array('required'=>'Należy podać login')),	
			'password' => new sfValidatorAnd(array(
				new sfValidatorString(array('required' => true, 'min_length' => 4),array('min_length' => 'Hasło musi posiadać min. 4 znaki')),
				new sfValidatorRegex(array('pattern' => '/^[0-9A-Za-z_.-]+$/'),array('invalid'=>'Dozwolone znaki to: a-zA-Z0-9_-.'))
			),array(),array('required'=>'Należy podać hasło'))
        ));

        $this->widgetSchema->setNameFormat('register[%s]');

        $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

        parent::setup();
    }
}
?>